package com.maxjay.component.metadata.model;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Record {
	
	private Map<String, Object> dataMap;
	
	public Record() {
		this.dataMap = new HashMap<String, Object>();
	}
	
	public Record(Map<String, Object> dataMap) {
		this.dataMap = dataMap;
	}
	
	public Set<String> fieldSet() {
		return dataMap.keySet();
	}

	/**
	 * 取得指定字段的值
	 * 
	 * @param fieldName
	 * @return
	 */
	public Object getValue(String fieldName) {
		return dataMap.get(fieldName);
	}
	
	/**
	 * 设置指定字段的值
	 * 
	 * @param fieldName
	 * @param fieldValue
	 */
	public void setValue(String fieldName, Object fieldValue) {
		this.dataMap.put(fieldName, fieldValue);
	}
	
	public Map<String, Object> getDataMap() {
		return dataMap;
	}

	public void setDataMap(Map<String, Object> dataMap) {
		this.dataMap = dataMap;
	}
	
	/**
	 * 是否包括指定的字段
	 * 
	 * @param fieldName
	 * @return
	 */
	public boolean containsField(String fieldName) {
		return dataMap.keySet().contains(fieldName);
	}
	
	public Set<String> getFieldNames() {
		return dataMap.keySet();
	}
	
	public String toString() {
		return dataMap.toString();
	}
}
